#include <string>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <time.h>
#include "includes.h"

using namespace std;

string getFileName();

int main(int argc, char** argv)
{
	string filename;
	if(argc > 1)
	{
		filename = argv[1];
	}
	else
	{
		filename = getFileName();
	}
	cout << "Creating simulation from \"" << filename << "\"." << endl;
	Scheduler* simulator = new Scheduler(filename);
	simulator->runSimulation();
}

string getFileName()
{
	ifstream ifs;
	string filename;
	while(true)
	{
		cout << "Please enter a valid filename for processor specifications:" << endl;
		cin >> filename;
		if(filename.length() == 0)
		{
			cout << "Filename invalid: no name given." << endl;
			continue;
		}
		ifs.open(filename.c_str());
		if(ifs.good())
		{
			return filename;
		}
		else
		{
			cout << "Filename invalid: No such file found." << endl;
		}
	}
}
